<?php
  @header("Content-Type:text/html;charset=utf-8");

  @include_once("conn.php");   // 引入conn.php (链接mysql)
  @include_once("common.php");



  if(!(isset($_POST["user"])&isset($_POST["pwd"])&isset($_POST["phone"])&isset($_POST["email"]))){
    paramsErr();
    // 做判断 请传入完整参数
  }

    //  把传入的参数获取过来
  $user = $_POST["user"];
  $pwd = $_POST["pwd"];
  $phone = $_POST["phone"];
  $email = $_POST["email"];


  $sql="insert into `userinfo`(user,pwd,phone,email) value('$user','$pwd','$phone','$email')";

  $result=mysqli_query($conn,$sql);

  $obj=array();
//   判断sql执行的结果
  if($result){
    $rows=mysqli_affected_rows($conn);

    if($rows>0){
        $obj["status"]=true;
        $obj["msg"]="注册成功";

    }else{
        $obj["status"]=false;
        $obj["msg"]="注册失败，数据未改变";
    }
  }else{
    $obj["status"] = false;
    $obj["msg"] = "sql语句有误";
    $obj["sql"] = $sql;
  }

  echo json_encode($obj);